function debounce(fn, time) {
    let t = null;

    return function() {
        if (t !== null) {
            clearInterval(t)
        }
        t = setTimeout(() => {
            fn.call(this)

        }, time)
    }
}